<?php
namespace api\common\tools;
require_once (MUMPHPI_MAINDIR . "/classes/lib/WxPay.Api.php");
require_once (MUMPHPI_MAINDIR . "/classes/lib/WxPay.NativePay.php");

class PayApi{
    public static function createNativePrePay($out_trade_no, $total_fee, $goods_tag, $product_id, $notify_url)
    {
        $notify = new NativePay();
        $input = new WxPayUnifiedOrder();
        $input->SetBody($goods_tag);
        $input->SetAttach($goods_tag);
        $input->SetOut_trade_no($out_trade_no);
        $input->SetTotal_fee($total_fee);
        $input->SetTime_start(date("YmdHis"));
        $input->SetTime_expire(date("YmdHis", time() + 600));
        $input->SetGoods_tag($goods_tag);
        $input->SetNotify_url($notify_url);
        $input->SetTrade_type("NATIVE");
        $input->SetProduct_id("test");
        $result = $notify->GetPayUrl($input);
        $url = $result["code_url"];
        return $url;
    }
    public static function orderQueryByOutTradeNo($out_trade_no)
    {
        $input = new WxPayOrderQuery();
        $input->SetOut_trade_no($out_trade_no);
        return WxPayApi::orderQuery($input);
    }

    public static function orderQueryByTransationId($transactionId)
    {
        $input = new WxPayOrderQuery();
        $input->SetTransaction_id($transactionId);
        return WxPayApi::orderQuery($input);
    }

}
?>
